#include"processbar.h"
#include<time.h>
#include<stdlib.h>
#define FILESIZE 1024*1024*1024

void download(callback_t cd)
{
  srand(time(NULL)^1023);
  int total = FILESIZE;
  while(total)
  {
    usleep(1000);
    int one = rand()%(1024*1024);
    total -= one;
    if(total < 0) total = 0;

    //当前的进度是多少？
    int download = FILESIZE - total;
    double rate = (download*1.0 /(FILESIZE))*100.0;
    cd(rate);
//    printf("download: %f\n",rate); //rate有啦，应该让进度条刷新


  }


}





int main()
{
 // process();
  download(process_flush);
  return 0 ;
}
